<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="md.utm.simple_jdbc.Person"%>
<%@page import="java.util.List"%>
<%@page import="md.utm.simple_jdbc.MySQLAccess"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<%
		// This is a scriptlet.  Notice that the "date"
		// variable we declare here is available in the
		// embedded expression later on.		
		MySQLAccess access = new MySQLAccess();
		List<Person> persons = access.readFromDataBase();
	%>
	<table border="2" style="font-size: large; font-weight: normal;">
		<thead align="center">
			<tr>
				<th>Name</th>
				<th>Surname</th>
				<th>Year of birth</th>
				<th>Age</th>
				<th>Is student</th>
			</tr>
		</thead>
		<%
			for (Person person : persons) {
		%>
		<tr>
			<td><%=person.getName()%></td>
			<td><%=person.getSurname()%></td>
			<td><%=person.getYearOfBirth()%></td>
			<td><%=Calendar.getInstance().get(Calendar.YEAR)-person.getYearOfBirth()%></td>
			<td><%=String.valueOf(person.isStudent())%></td>
		</tr>
		<%
			}
		%>
	</table>
	<p>
	<a href="insertperson.jsp">Insert a new person</a>
</body>
</html>